
package org.streets.eis.ext.analysis.internal.impl;
import org.slf4j.Logger;
import org.streets.commons.util.StringUtils;
import org.streets.database.SQLConnection;
import org.streets.database.datadict.DataDict;
import org.streets.database.datadict.TableRelations;
import org.streets.eis.entity.User;
import org.streets.eis.ext.analysis.entities.JoinTable;
import org.streets.eis.ext.analysis.entities.QueryStruct;


public class IdentifierSqlExtenderImpl extends SqlExtenderImpl{
	private static final long serialVersionUID = 1L;
	
	public IdentifierSqlExtenderImpl(Logger logger, DataDict dict,TableRelations relations,SQLConnection connection) {
		super(logger, dict,relations,connection);
	}

	
	/**
	 * 给表加上ID;
	 * tablename.id,
	 */
	@Override	
	public QueryStruct extend(User user,QueryStruct struct) {
		for(JoinTable table : struct.getTables()){
			String alias = table.getAlias();
			if(StringUtils.isEmpty(alias)) {
				struct.getIdFields().add(table.getTableDef().getName()+".id");
			}else{
				struct.getIdFields().add(alias + ".id");
			}
		}
		
		return struct;
	}
	
	
   
 


 

 
 
}
